package com.yxmadoc.umlproject.controller;

import com.alibaba.fastjson.JSONObject;
import com.yxmadoc.umlproject.config.enums.ReturnResult;
import com.yxmadoc.umlproject.model.Repairer;
import com.yxmadoc.umlproject.service.RepairerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class RepairerController {

    @Autowired
    private RepairerService repairerService;

    @PostMapping("/repairer")
    public JSONObject insert(@RequestBody Repairer repairer){
        JSONObject result = new JSONObject();
        result.put(ReturnResult.DATA.getCode(), repairerService.save(repairer));
        return result;
    }

    @GetMapping("/repairer/{repairerId}")
    public JSONObject detail(@PathVariable("repairerId")String repairerId){
        JSONObject data = new JSONObject();
        data.put(ReturnResult.DATA.getCode(), repairerService.findOne(repairerId));
        return data;
    }



}
